import { http } from "@/request/axios";
// 接口
const api = {
  //upload or download
  upload: "/common/upload",

  login: "/user/login",
  register: "/user/register",
  getUser: "/user/getUser",
  delUser: "/user/removeUser",
  updateUserStatus: "/user/userStatusManage",
  updatePerMsg: "/user/updateMessage",
  getUserById: "/user/getUserById",
  //帖子
  getPosts: "/post/getPostObscure",
  delPost: "/post/removePost",
  auditPost: "/post/auditPost",
  getPostObscure: "/post/getPostObscure",
  getPostByUser: "/post/getPostByUser",
  publishPostByUser: "/post/addPostByUser",
  getPostById: "/post/getPostById",
  updatePost: "/post/updatePost",
  getOwnPost: "/post/getOwnPost",
  // 评论
  getPostComment: "/comment/getPostComment",
  commentPost: "/comment/commentPost",
  replyPost: "/comment/commentPostAnswer",
  delPostComment: "/comment/removeOwnComment",
  // 类型
  getType: "/user/getType",
  editType: "/user/updateType",
  addType: "/user/addType",
  delType: "/user/deleteType",

  //省市区
  getCity: "/city/getCity",

  //课题
  getVideo: "/subject/getSubject",
  delVideo: "/subject/deleteSubject",
  updateVideo: "/subject/updateSubject",
  updateVideoStatus: "/video/updateVideoStatus",
  getSubject: "/subject/getSubject",
  addVideoByUser: "/subject/addSubject",
  getOtherVideo: "/subject/applySubject",
  getVideoById: "/subject/getDetailSubject",
  getOwnVideo: "/subject/getOwnSubject",
  auditVideo: "/video/auditVideo",
  otherGetOwnVideo: "/apply/otherGetOwnVide",
  getVideoApplication: "/video/getVideoApplication",
  auditSubject: "/subject/auditSubject",
  getSubjectByAdmin: "/subject/getSubjectByAdmin",
  // 视频申请
  auditOthers: "/apply/auditOthers",
  getApply: "/apply/getApply",

  //课程
  getCourse: "/video/getVideo",
  delCourse: "/video/removeVideo",
  updateCourse: "/video/updateVideo",
  addVideo: "/video/addVideo",
};

//请求
export const login = (data = {}) => {
  return http({
    url: api.login,
    method: "post",
    data,
  });
};
export const userRegister = (data = {}) => {
  return http({
    url: api.register,
    method: "post",
    data,
  });
};

export const getUser = (params = {}) => {
  return http({
    url: api.getUser,
    method: "get",
    params,
  });
};

export const delUser = (data: React.Key[] = []) => {
  return http({
    url: api.delUser,
    method: "post",
    data,
  });
};
export const updateUserStatus = (data: React.Key[] = []) => {
  return http({
    url: api.updateUserStatus,
    method: "put",
    data,
  });
};

//帖子
export const getPosts = (params = {}) => {
  return http({
    url: api.getPosts,
    method: "get",
    params,
  });
};
export const delPost = (data = {}) => {
  return http({
    url: api.delPost,
    method: "post",
    data,
  });
};
export const auditPost = (data = {}) => {
  return http({
    url: api.auditPost,
    method: "post",
    data,
  });
};
export const getPostObs = (params = {}) => {
  return http({
    url: api.getPostObscure,
    method: "get",
    params,
  });
};
export const getType = (params = {}) => {
  return http({
    url: api.getType,
    method: "get",
    params,
  });
};
export const updatePerMsg = (data = {}) => {
  return http({
    url: api.updatePerMsg,
    method: "post",
    data,
  });
};
export const getVideo = (params = {}) => {
  return http({
    url: api.getVideo,
    method: "get",
    params,
  });
};

export const addVideo = (data = {}) => {
  return http({
    url: api.addVideo,
    method: "post",
    data,
  });
};
export const getCity = () => {
  return http({
    url: api.getCity,
    method: "get",
  });
};
export const upload = (data: any) => {
  return http({
    url: api.upload,
    method: "post",
    data,
  });
};
export const editType = (data: any) => {
  return http({
    url: api.editType,
    method: "put",
    data,
  });
};
export const delType = (data: any = []) => {
  return http({
    url: api.delType,
    method: "put",
    data,
  });
};
export const addType = (data: any = {}) => {
  return http({
    url: api.addType,
    method: "post",
    data,
  });
};
export const delVideo = (params: any = []) => {
  return http({
    url: api.delVideo,
    method: "post",
    params,
  });
};
export const updateVideo = (data: any = {}) => {
  return http({
    url: api.updateVideo,
    method: "post",
    data,
  });
};
export const updateVideoStatus = (data: any = {}) => {
  return http({
    url: api.updateVideoStatus,
    method: "post",
    data,
  });
};
export const getSubject = (params: any = {}) => {
  return http({
    url: api.getSubject,
    method: "get",
    params,
  });
};

export const getPostByUser = (params: any = {}) => {
  return http({
    url: api.getPostByUser,
    method: "get",
    params,
  });
};

export const publishPostByUser = (data: any = {}) => {
  return http({
    url: api.publishPostByUser,
    method: "post",
    data,
  });
};

export const getPostById = (params: any = {}) => {
  return http({
    url: api.getPostById,
    method: "get",
    params,
  });
};

export const getPostComment = (params: any = {}) => {
  return http({
    url: api.getPostComment,
    method: "get",
    params,
  });
};

export const commentPost = (data: any = {}) => {
  return http({
    url: api.commentPost,
    method: "post",
    data,
  });
};

export const updatePost = (data: any = {}) => {
  return http({
    url: api.updatePost,
    method: "put",
    data,
  });
};

export const getUserById = (params: any = {}) => {
  return http({
    url: api.getUserById,
    method: "get",
    params,
  });
};

export const addVideoByUser = (data: any = {}) => {
  return http({
    url: api.addVideoByUser,
    method: "post",
    data,
  });
};

export const getOtherVideo = (data: any = {}) => {
  return http({
    url: api.getOtherVideo,
    method: "post",
    data,
  });
};

export const getVideoById = (params: any = {}) => {
  return http({
    url: api.getVideoById,
    method: "get",
    params,
  });
};

export const getOwnPost = (params: any = {}) => {
  return http({
    url: api.getOwnPost,
    method: "get",
    params,
  });
};

export const getOwnVideo = (params: any = {}) => {
  return http({
    url: api.getOwnVideo,
    method: "get",
    params,
  });
};

export const auditVideo = (data: any = {}) => {
  return http({
    url: api.auditVideo,
    method: "post",
    data,
  });
};

export const replyPost = (data = {}) => {
  return http({
    url: api.replyPost,
    method: "post",
    data,
  });
};

export const delPostComment = (params = {}) => {
  return http({
    url: api.delPostComment,
    method: "post",
    params,
  });
};

export const otherGetOwnVideo = (params = {}) => {
  return http({
    url: api.otherGetOwnVideo,
    method: "get",
    params,
  });
};

export const getVideoApplication = (params = {}) => {
  return http({
    url: api.getVideoApplication,
    method: "get",
    params,
  });
};
export const auditOthers = (params = {}) => {
  return http({
    url: api.auditOthers,
    method: "post",
    params,
  });
};
export const getCourse = (params = {}) => {
  return http({
    url: api.getCourse,
    method: "get",
    params,
  });
};
export const delCourse = (data: []) => {
  return http({
    url: api.delCourse,
    method: "post",
    data,
  });
};
export const updateCourse = (data: {}) => {
  return http({
    url: api.updateCourse,
    method: "post",
    data,
  });
};
export const auditSubject = (params: {}) => {
  return http({
    url: api.auditSubject,
    method: "get",
    params,
  });
};
export const getSubjectByAdmin = (params: {}) => {
  return http({
    url: api.getSubjectByAdmin,
    method: "get",
    params,
  });
};
export const getApply = (params: {}) => {
  return http({
    url: api.getApply,
    method: "get",
    params,
  });
};
